package JFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * @author DONG
 */
public class StartJFrame extends JFrame {
    public StartJFrame(String id) {
        JFrame frame = new JFrame("游戏宝库");

        frame.setBounds(20, 20, 910, 720);
        //窗口大小不可变
        frame.setResizable(false);
        frame.setVisible(true);

        frame.add(new StartPanel(id));
    }
}

class StartPanel extends JPanel {
    @Override
    protected void paintComponent(Graphics g) {
        Data.back.paintIcon(this, g, 0, 0);
    }
    public StartPanel(String id) {
        this.setBackground(Color.white);
        this.setVisible(true);
        this.setBounds(0, 0, 910, 720);
        this.setLayout(new GridLayout(3, 2, 20, 80));

        JButton startgame1jButton = new JButton("贪吃蛇游戏");
        startgame1jButton.setContentAreaFilled(false); //透明
        startgame1jButton.setFont(new Font("黑体", Font.LAYOUT_LEFT_TO_RIGHT, 28));//字体
        //startgamejButton.setBounds(0,0,50,50);
        startgame1jButton.setBackground(Color.white);
        startgame1jButton.setBorder(null);
        startgame1jButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                new SnackJFrame(id);
            }
        });
        JButton rankListJButton = new JButton("贪吃蛇排名");
        rankListJButton.setContentAreaFilled(false); //透明
        rankListJButton.setFont(new Font("黑体", Font.LAYOUT_LEFT_TO_RIGHT, 20));//字体
        //startgamejButton.setBounds(0,0,50,50);
        rankListJButton.setBackground(Color.white);
        rankListJButton.setBorder(null);
        rankListJButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                new SnackRanking();
            }
        });

        JButton startgame2jButton = new JButton("五子棋游戏");
        startgame2jButton.setContentAreaFilled(false); //透明
        startgame2jButton.setFont(new Font("黑体", Font.LAYOUT_LEFT_TO_RIGHT, 28));//字体
        startgame2jButton.setBackground(Color.white);
        startgame2jButton.setBorder(null);
        startgame2jButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                new GobangFrame();
            }
        });
        JButton startgame3Button = new JButton("贪吃蛇游戏加速版");
        startgame3Button.setContentAreaFilled(false); //透明
        startgame1jButton.setFont(new Font("黑体", Font.LAYOUT_LEFT_TO_RIGHT, 28));//字体
        startgame3Button.setBackground(Color.white);
        startgame3Button.setBorder(null);
        startgame3Button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                new SnackJFrame_nan(id);
            }
        });

        this.add(startgame1jButton);
        this.add(rankListJButton);
        this.add(startgame2jButton);
        this.add(startgame3Button);

    }
}